#!/usr/bin/env bash
#create by Arnold.zhu
echo "Please input application num"
read num

echo "Waiting..."

if [ "$num" = 1 ]; then
   port=8080
else
   port=8082
fi

PID=$(ps -ef | grep $port | grep -v grep | awk '{ print $2 }')

if [ -z "$PID" ]; then
    echo "Application is already stopped"
else
    echo "kill $PID"
    kill $PID
fi